import { _decorator, Component, instantiate, Node, Prefab, Vec3 } from 'cc';
import { Fish } from './Fish';
const { ccclass, property } = _decorator;

@ccclass('CollectLoad')
/**
 * 收集层
 */
export class CollectLoad extends Component {

    //小鱼预设体
    @property(Prefab)
    private Fish: Prefab = null;

    //宽高
    private CollectWidth: number = 400;
    private CollectHeight: number = 60;

    /**
     * 添加鱼
     */
    public AddFish(_index: number, _pos: Vec3) {
        let fish: Node = instantiate(this.Fish);
        this.node.addChild(fish);
        fish.setPosition(new Vec3(-this.CollectWidth / 2 + Math.random() * this.CollectWidth, -this.CollectHeight / 2 + Math.random() * this.CollectHeight));
        fish.getComponent(Fish).UpdateFish1(_index, _pos);
    }

}


